﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MusicExplorer.WebRepository.Service;
using MusicExplorer.Wrappers;

namespace MusicExplorer.ViewModel.Popup
{
    public class WebRepositoryGroupPreferencesViewModel : EntityPreferencesViewModel
    {
        private WebRepositoryGroupWrapper m_groupWrapper;

        public WebRepositoryGroupPreferencesViewModel(MainWindowViewModel parent, WebRepositoryGroupWrapper groupWrapper)
            : base(parent)
        {
            m_groupWrapper = groupWrapper;

            var allRepositories = ServiceWebRepository.GetWebRepositoriesFromType(groupWrapper.TypeWebRepositories);

            foreach (var a in allRepositories.Where(a => a.web_repo_visibility).OrderBy(a => a.web_repo_order).Select(a => new DetailTreeItemWrapper(a))) m_enableEntities.Add(a);
            foreach (var a in allRepositories.Where(a => !a.web_repo_visibility).OrderBy(a => a.web_repo_order).Select(a => new DetailTreeItemWrapper(a))) m_disableEntities.Add(a);
        }

        public override bool CanAddEntity { get { return false; } }

        public override string EntityName { get { return "Repository"; } }

        public override string EntityPluralName { get { return "Repositories"; } }

        protected override bool SearchEntityFromTerms() { return false; }
    }
}
